home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 May: Tool Chest / Developer CD Series May 1996 (Tool Chest) (Apple Computer) (1996).iso / Sample Code / AppsToGo / DTS.Lib / DTS.Lib.headers / ListControl.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-09-22  |  31.0 KB  |  777 lines  |  [TEXT/MPS ]

  1. #ifndef __LISTCONTROL__
  2. #define __LISTCONTROL__
  3.  
  4. #ifndef __TYPES__
  5. #include <Types.h>
  6. #endif
  7.  
  8. #ifndef __LISTS__
  9. #include <Lists.h>
  10. #endif
  11.  
  12. #ifndef __WINDOWS__
  13. #include <Windows.h>
  14. #endif
  15.  
  16. typedef void    (*CLGetCompareDataProcPtr)(void *src, short srclen, void *dst, short *dstlen);
  17. typedef short    (*CLDoCompareDataProcPtr)(void *ptra, void *ptrb, short lena, short lenb);
  18. typedef Boolean    (*CLKeyFilterProcPtr)(ListHandle list, EventRecord *event);
  19.  
  20. typedef struct CLDataRec {
  21.     short                    mode;
  22.     CLGetCompareDataProcPtr    getCompareData;
  23.     CLDoCompareDataProcPtr    doCompareData;
  24.     CLKeyFilterProcPtr        keyFilter;
  25. } CLDataRec;
  26. typedef CLDataRec *CLDataPtr, **CLDataHndl;
  27.  
  28.  
  29.  
  30. #ifdef __cplusplus
  31. extern "C" {
  32. #endif
  33.  
  34.  
  35.  
  36. void            CLActivate(Boolean makeActive, ListHandle listHndl);
  37.     /*
  38.     **    ¶ Change activate state of list control to designated state.
  39.     **
  40.     **    INPUT:    aboveLayer        This is the layer above the layer to create.
  41.     **    INPUT:    makeActive:        true to make the control the active control.
  42.     **                            false to inactivate the control.
  43.     **            listHndl:        The list to activate or deactivate.
  44.     **
  45.     **    Activate this List record.  Activation is not done by calling LActivate.  The active
  46.     **    control is indicated by the 2-pixel thick border around the List control.  This allows
  47.     **    all List controls in a window to display which cells are selected.  This behavior can
  48.     **    be overridden by calling LActivate on the List record for List controls.
  49.     **
  50.     **    Human interface dictates that at most only a single List control has this active border.
  51.     **    For this reason, this function scans for other List controls in the window and removes
  52.     **    the border from any other that it finds. */
  53.  
  54. Boolean            CLClick(WindowPtr window, EventRecord *event, short *action);
  55.     /*
  56.     **    ¶ Handle a mouseDown for a list control.
  57.     **
  58.     **    INPUT:    window        The window to check for a List control click in.
  59.     **            event        The mouseDown event.
  60.     **    OUTPUT:    action        Pointer to a short to hold the resulting action.
  61.     **                        Pass in nil if you don't care.
  62.     **                            If 0 returned:    No action taken.
  63.     **                            If 1 returned:    The active list control used the click.
  64.     **                            If -1 returned:    A new List control was activated
  65.     **                                            (and the old one deactivated.)
  66.     **    RESULT:    Boolean        True if a List control used the event.
  67.     **
  68.     **    This is called when a mouseDown occurs in the content of a window.  It returns true if the
  69.     **    mouseDown caused a List action to occur.  Events that are handled include if the user
  70.     **    clicks on a scrollbar that is associated with a List control. */
  71.  
  72. ControlHandle    CLCtlHit(void);
  73.     /*
  74.     **    ¶ Return List control that was found by last call to FindControl.
  75.     **
  76.     **    RESULT:    ControlHandle
  77.     **
  78.     **    The List control that was hit by calling FindControl is saved in a global variable, since
  79.     **    the CDEF has no way of returning what kind it was.  To determine that it was a List control
  80.     **    that was hit, first call this function.  The first call returns the old value in the global
  81.     **    variable, plus it resets the global to nil.  Then call FindControl, and then call this
  82.     **    function again.  If it returns nil, then a List control wasn't hit.  If it returns non-nil,
  83.     **    then it was a List control that was hit, and specifically the one returned. */
  84.  
  85. Boolean            CLEvent(WindowPtr window, EventRecord *event, short *action);
  86.     /*
  87.     **    ¶ Handle the event if it applies to the active List control.
  88.     **
  89.     **    INPUT:    window        The window the event should be processed in.
  90.     **            event        The event to be processed.
  91.     **            action:        Used to return the action taken by CLClick.
  92.     **                        Pass in nil if you don't care.
  93.     **                        For click events:
  94.     **                            If 0 returned:    No action taken.
  95.     **                            If 1 returned:    The active list control used the click.
  96.     **                            If -1 returned:    A new List control was activated
  97.     **                                            (and the old one deactivated.)
  98.     **                        For key events:
  99.     **                            If 0 returned:     No action taken.
  100.     **                            If 1 returned:     Key positioning occured on the active control.
  101.     **
  102.     **    RESULT:    Boolean        True if a List control used the event.
  103.     **
  104.     **    Handle the event if it applies to the active List control.  If some action occured due
  105.     **    to the event, return true. */
  106.  
  107. ListHandle        CLFindActive(WindowPtr window);
  108.     /*
  109.     **    ¶ Returns the active List control, if any.
  110.     **
  111.     **    INPUT:    window        The window to check for an active List control.
  112.     **    RESULT:    ListHandle    The active List control found (nil if none).
  113.     **
  114.     **    Returns the active List control, if any.  If nil is passed in, then the return value
  115.     **    represents whatever List control is active, independent of what window it is in.  If a
  116.     **    window is passed in, then it returns a List control only if the active control is in the
  117.     **    specified window.  If the active List control is in some other window, then nil
  118.     **    is returned. */
  119.  
  120. ControlHandle    CLFindCtl(WindowPtr window, EventRecord *event, ListHandle *listHndl,
  121.                           ControlHandle *ctlHit);
  122.     /*
  123.     **    ¶ See if a List control or related scrollbar was clicked on.
  124.     **
  125.     **    INPUT:    window            The window to check for a hit.
  126.     **            event            The mouseDown event to hit-test with.
  127.     **    OUTPUT:    listHndl        The list hit on, or nil if none hit.
  128.     **                            Pass in nil if you don’t care.
  129.     **            ctlHit            The control hit on, or nil if none hit.
  130.     **                            Pass in nil if you don’t care.
  131.     **                            (Note that the control returned here may be a related scrollbar.)
  132.     **    RESULT:    ControlHandle    The List control hit, or nil for none.
  133.     **
  134.     **    This determines if a List control was clicked on, or if a related scrollbar was
  135.     **    clicked on.  If a List control or List scrollbar was clicked on, then true is returned,
  136.     **    as well as the List handle and the handle to the view control. */
  137.  
  138. ListHandle        CLFromScroll(ControlHandle scrollCtl, ControlHandle *retCtl);
  139.     /*
  140.     **    ¶ Find the List record that is related to the indicated scrollbar.
  141.     **
  142.     **    INPUT:    scrollCtl        The scrollbar to look up.
  143.     **            retCtl            The List control handle.  Pass in nil if you don’t care.
  144.     **    RESULT:    listHndl        The list related to the scrollbar.
  145.     **
  146.     **    Find the List record that is related to the indicated scrollbar. */
  147.  
  148. ListHandle        CLGetList(WindowPtr window, short lnum);
  149.     /*
  150.     **    ¶ Get the Nth List control in the control list of a window.
  151.     **
  152.     **    INPUT:    window        The window whose control list is to be scanned.
  153.     **            lnum        The list number to return.
  154.     **    RESULT:    listHndl    The Nth list control in the window list.
  155.     **
  156.     **    Get the Nth List control in the control list of a window. */
  157.  
  158. short            CLInsert(ListHandle listHndl, char *data, short dataLen, short row, short col);
  159.     /*
  160.     **    ¶ Insert a cell alphabetically into the list.
  161.     **
  162.     **    INPUT:    listHndl    The list to be inserted into.
  163.     **            data        Pointer to data to insert.
  164.     **            dataLen        Length of data to insert.
  165.     **            row            Row to insert into (or -1 if to be determined).
  166.     **            col            Column to insert into (or -1 if to be determined).
  167.     **    RESULT:    short        The position at which the data was inserted.
  168.     **
  169.     **    Insert a cell alphabetically into the list.  Whichever parameter is passed in as -1, either
  170.     **    row or column, that is the dimension that is determined.  The method of handling he
  171.     **    comparisons has been changed to allow customization of the list data and search methods.
  172.     **    Before, it was assumed that the cell content was text, and that the default LDEF was being
  173.     **    used.  If you write a custom LDEF that uses a different data format, you had problems before.
  174.     **    Now, with the addition of two procedure pointers, you can customize the data comparisons.
  175.     **    The two new procs are:
  176.     **        1) getCompareData
  177.     **        2) doCompareData
  178.     **    The first proc, getCompareData, if nil, simply gets the data out of the cell for comparison
  179.     **    purposes.  If it is not nil, then the proc is called, and the proc gets the data out of the
  180.     **    cell.  The proc can then get whatever data it needs to for the purpose of comparing to other
  181.     **    cells and finding the insert location in the list.  The second proc, doCompareData, if nil
  182.     **    tells the List control to call IUMagString for the purpose of comparison.  If it is not nil,
  183.     **    then the proc is called instead of IUMagString, and you can do whatever kind of comparison
  184.     **    you wish.  Your proc is a replacement for IUMagString, so it should be of that form, except
  185.     **    that the prototype is a C prototype, instead of type pascal.
  186.     **
  187.     **    The prototypes are:
  188.     **
  189.     **    typedef void  (*CLGetCompareDataProcPtr)(void *src, short srclen, void *dst, short *dstlen);
  190.     **    typedef short (*CLDoCompareDataProcPtr)(void *ptra, void *ptrb, short lena, short lenb);
  191.     **
  192.     **    The GetCompareData proc is passed in a reference to the data, and a length.  Its job is to
  193.     **    then return the data and data length of what the compare data should look like.
  194.     **
  195.     **    The DoCompareData proc is just a replacement for IUMagString.  Parameters are as expected.
  196.     **    To set the procs, you first need to have a List control.  The below example assumes that
  197.     **    the window has a single List control.
  198.     **
  199.     **
  200.     **    static short    MyDoCompareData(void *ptra, void *ptrb, short lena, short lenb);
  201.     **    static void        MyGetCompareData(void *src, short srclen, void *dst, short *dstlen);
  202.     **    static Boolean    MyKeyFilter(ListHandle list, EventRecord *event);
  203.     **
  204.     **        ControlHandle    ctl;
  205.     **        ListHandle        list;
  206.     **        CLDataHndl        listData;
  207.     **
  208.     **        ctl = CLNext(window, &list, nil, 1, false);
  209.     **        listData = (CLDataHndl)(*ctl)->contrlData;
  210.     **        (*listData)->getCompareData = MyGetCompareData;
  211.     **        (*listData)->doCompareData  = MyDoCompareData;
  212.     **        (*listData)->keyFilter      = MyKeyFilter;
  213.     **
  214.     **            The above code first gets the first (only) List control in window.  It then gets
  215.     **            the listData record so that it can store the compare procs into the list.  The
  216.     **            procs are then stored into the record.
  217.     */
  218.  
  219. Boolean            CLKey(WindowPtr window, EventRecord *event);
  220.     /*
  221.     **    ¶ Handle a keypress for a list control.
  222.     **
  223.     **    INPUT:    window        The window to check for a List control keypress in.
  224.     **            event        The keypress event.
  225.     **    RESULT:    Boolean        True if a List control used the event.
  226.     **
  227.     **    See if the keypress event applies to the List control, and if it does, handle it and
  228.     **    return true.  The keypress can only be used by the List control if the List control
  229.     **    has key-positioning set. */
  230.  
  231. ListHandle        CLNew(short viewID, Boolean vis, Rect *vRect, short numRows, short numCols,
  232.                       short cellHeight, short cellWidth, short theLProc,
  233.                       WindowPtr window, short mode);
  234.     /*
  235.     **    ¶ Create a List control for the window.
  236.     **
  237.     **    This List control implementation does the following:
  238.     **
  239.     **    1)    Makes using lists in a non-dialog window easier.
  240.     **    2)    The List is automatically associated with the window, since
  241.     **        it is in the window's control list.
  242.     **    4)    Updating of the List is much simpler, since all that is
  243.     **        necessary is to draw the control (or all the window's controls with
  244.     **        a DrawControls call).
  245.     **    5)    What isn't handled automatically by tracking the control can be handled
  246.     **        with a direct call.  There are simple calls to handle List events.
  247.     **    6)    When you close the window, the ListRecord is disposed of.
  248.     **        (This automatic disposal can easily be defeated.)
  249.     **
  250.     **    To create a List control, you only need a single call.  For example:
  251.     **
  252.     **        list = CLNew(rViewCtl,            Resource ID of view control for List control.
  253.     **                     true,                Initially visible.
  254.     **                     &viewRect,            View rect of list.
  255.     **                     numRows,            Number of rows to create List with.
  256.     **                     numCols,            Number of columns to create List with.
  257.     **                     cellHeight,
  258.     **                     cellWidth,
  259.     **                     theLProc,            Custom List procedure resource ID.
  260.     **                     window,            Window to hold List control.
  261.     **                     clHScroll | blBrdr | clActive);    Horizontal scrollbar, active List.
  262.     **
  263.     **    The various choices for the List control are defined as follows:
  264.     **
  265.     **    #define clHScroll        0x0002
  266.     **    #define clVScroll        0x0008
  267.     **    #define clActive        0x0020
  268.     **    #define clShowActive    0x0040
  269.     **    #define clKeyPos        0x0080
  270.     **    #define clTwoStep        0x0100
  271.     **    #define clHasGrow        0x0200
  272.     **    #define clDrawIt        0x8000
  273.     **
  274.     **    clHScroll:        Create a list that includes a horizontal scrollbar.
  275.     **    clVScroll:        Create a list that includes a vertical scrollbar.
  276.     **    clActive:        Make this the initially active control for the window.
  277.     **    clShowActive:    When the control is active, show that it is by drawing a selection
  278.     **                    border around the control.  This is the new 7.0 human-interface
  279.     **                    method of showing which control is active.  (It also works in system 6.)
  280.     **    clKeyPos:        Allow list positioning, based on user keypresses.  This assumes that
  281.     **                    the list is alphabetized so that key presses for location make sense.
  282.     **                    If typing by the user is fast enough, multiple characters will be
  283.     **                    used for the positioning.
  284.     **    clTwoStep:        When using IsCtlEvent(), you may want the initial click on a List
  285.     **                    control to just select the control, or you may wish the click to start
  286.     **                    tracking in addition to selecting the control.  The tracking is
  287.     **                    considered the second step.  By setting this bit, you indicate that you
  288.     **                    want control selection and item selection to be a 2-step process.
  289.     **                    Setting this bit means that it will take 2 separate clicks by the
  290.     **                    user to select an item in the list if the list is inactive.
  291.     **    clHasGrow:        This makes sure that there is space for the growIcon if the list
  292.     **                    has a scrollbar.  If the list occupies an entire window, then if there
  293.     **                    is only one scrollbar, the scrollbar has to be shrunk to make room
  294.     **                    for the growIcon.  The List Manager supposedly has this ability, but
  295.     **                    it doesn't work.  The List control manages it correctly.
  296.     **    clDrawIt:        This is a List manager flag that is needed for the LNew() call.
  297.     **
  298.     **
  299.     **    If the CLNew call succeeds, you then have a List control in your window.  It will be
  300.     **    automatically disposed of when you close the window.  If you don't want this to happen,
  301.     **    then you can detach it from the view control which owns it.  To do this, you would to
  302.     **    the following:
  303.     **
  304.     **        viewCtl = CLViewFromList(theListHndl);
  305.     **        if (viewCtl) SetCRefCon(viewCtl, nil);
  306.     **
  307.     **    The view control keeps a reference to the List record in the refCon.  If the refCon is
  308.     **    cleared, then the view control does nothing.  So, all that is needed to detach a List
  309.     **    record from a view control is to set the view control's refCon nil.  Now if you close the
  310.     **    window, you will still have the List record.
  311.     **
  312.     **
  313.     **    To remove a List control completely from a window, just dispose of the view
  314.     **    control that holds the List record.  To do this, just do something like the below:
  315.     **
  316.     **        DisposeControl(CLViewFromList(theListHndl));
  317.     **
  318.     **    This completely disposes of the List control.
  319.     **
  320.     **
  321.     **    Events for the List record are handled nearly automatically.  Just make the following call:
  322.     **
  323.     **        CLEvent(window, eventPtr, &action);
  324.     **
  325.     **    If the event was handled, true is returned.  If the event is false, then the event doesn't
  326.     **    belong to a List control, and further processing of the event should be done.
  327.     */
  328.  
  329. ControlHandle    CLNext(WindowPtr window, ListHandle *listHndl, ControlHandle ctl,
  330.                        short dir, Boolean justActive);
  331.     /*
  332.     **    ¶ Get the next List control in the window.
  333.     **
  334.     **    INPUT:    window            The window to check for a List control keypress in.
  335.     **            ctl                The last control found (nil searchs from beginning of control list).
  336.     **            dir                Search direction (1 for forward, -1 for backward).
  337.     **            justActive        True if only active, visible controls should be returned.
  338.     **    RESULT:    ControlHandle    Next control found, based on criteria.
  339.     **
  340.     **    Get the next List control in the window.  You pass it a control handle for the view control,
  341.     **    or nil to start at the beginning of the window.  It returns both a List handle and the view
  342.     **    control handle for that List record.  If none is found, nil is returned.  This allows you to
  343.     **    repeatedly call this function and walk through all the List controls in a window. */
  344.  
  345. void            CLPrint(RgnHandle clipRgn, ListHandle listHndl, short *row, short *col,
  346.                         short leftEdge, Rect *drawRct);
  347.     /*
  348.     **    ¶ Print List Control cells into the designated rectangle.
  349.     **
  350.     **    INPUT:    clipRgn            Region to clip output to.
  351.     **            listHndl        List to print.
  352.     **            leftEdge        Don’t print cells left of this column.
  353.     **    IN/OUT    row                Starting row to print (first row not printed returned here).
  354.     **            col                Starting column to print (first column not printed returned here).
  355.     **            drawRct            Print cells inside rect.  Rect is also shrunk to bound the
  356.     **                            cells that did print.
  357.     **
  358.     **    From the starting row or column, print as many cells as will fit into the designated rect.
  359.     **    Pass in a starting row and column, and they will be adjusted to indicate the first cell
  360.     **    that didn't fit into the rect.  If all remaining cells were printed, the row is returned
  361.     **    as -1.  The bottom of the rect to print in is also adjusted to indicate where the actual
  362.     **    cut-off point was. */
  363.  
  364. short            CLRowOrColSearch(ListHandle listHndl, void *data, short dataLen,
  365.                                  short row, short col);
  366.     /*
  367.     **    ¶ Find the location in the list where the data would belong if inserted.
  368.     **
  369.     **    INPUT:    listHndl        List to search.
  370.     **            data            Pointer to data to search for, of whatever type.
  371.     **            dataLen            Length of data to search for.
  372.     **            row                Row to restrict search to, or -1 if doing row search.
  373.     **            col                Column to restrict search to, or -1 if doing column search.
  374.     **    RESULT:    short            Insertion location for either row or column.
  375.     **
  376.     **    Find the location in the list where the data would belong if inserted.  The row and column
  377.     **    are passed in.  If either is -1, that is the dimension that will be determined and returned.
  378.     **    The two comparison procs getCompareData and doCompareData are used in this function.
  379.     **
  380.     **    __________
  381.     **
  382.     **    Also see:    CLInsert. */
  383.  
  384. void            CLUpdate(RgnHandle clipRgn, ListHandle list);
  385.     /*
  386.     **    ¶ Draw the List control in the correct mode.
  387.     **
  388.     **    INPUT:    clipRgn        Draw only within this region.
  389.     **            list        List to draw.
  390.     **
  391.     **    Draw the List control in the correct mode. */
  392.  
  393. ControlHandle    CLViewFromList(ListHandle listHndl);
  394.     /*
  395.     **    ¶ Given a list, return the related wrapper control.
  396.     **
  397.     **    INPUT:    listHndl        List assumably wrapped by a control.
  398.     **    RESULT:    ControlHandle    Control wrapping list (or nil if none).
  399.     **
  400.     **    Return the control handle for the view control that owns the List record.  Use this to find
  401.     **    the view to do customizations such as changing the update procedure for this List control. */
  402.  
  403. ListHandle        CLWindActivate(WindowPtr window, Boolean displayIt);
  404.     /*
  405.     **    ¶ Given a list, return the related wrapper control.
  406.     **
  407.     **    INPUT:    listHndl        List assumably wrapped by a control.
  408.     **    RESULT:    ControlHandle    Control wrapping list (or nil if none).
  409.     **
  410.     **    This window is becoming active or inactive.  The borders of the List controls need to be
  411.     **    redrawn due to this.  For each List control in the window, redraw the active border. */
  412.  
  413. void            CLSize(ListHandle list, short newH, short newV);
  414.     /*
  415.     **    ¶ Resize the control and related things.
  416.     **
  417.     **    INPUT:    list        List to resize.
  418.     **            newH        New width for control.
  419.     **            newV        New height for control.
  420.     **
  421.     **    This resizes the list and it's viewCtl  All parts are resized, including the scrollbars,
  422.     **    and active indicator. */
  423.  
  424. void            CLMove(ListHandle list, short newH, short newV);
  425.     /*
  426.     **    ¶ Move the control and related things.
  427.     **
  428.     **    INPUT:    list        List to move.
  429.     **            newH        New horizontal location for control.
  430.     **            newV        New vertical location for control.
  431.     **
  432.     **    This moves the list and it's viewCtl  All parts are moved, including the scrollbars,
  433.     **    and active indicator. */
  434.  
  435. void            CLShow(ListHandle list);
  436.     /*
  437.     **    ¶ Show the control and related things.
  438.     **
  439.     **    INPUT:    list        List to show.
  440.     **
  441.     **    This shows the list and related parts, including the scrollbars and active indicator. */
  442.  
  443. Rect            CLHide(ListHandle list);
  444.     /*
  445.     **    ¶ Hide the control and related things.
  446.     **
  447.     **    INPUT:    list        List to hide.
  448.     **
  449.     **    This hides the list and related parts, including the scrollbars and active indicator. */
  450.  
  451. void            CLVInitialize(void);
  452.     /*
  453.     **    ¶ Initialize variable-sized cells List control code.
  454.     **
  455.     **    Call this upon startup of any application that wants to be able to use the
  456.     **    variable-size cell feature of the List control.  For AppsToGo-created List control
  457.     **    definitions to be variable-size automatically, this must be called first.  You can
  458.     **    call CLVVariableSizeCells at a later time to utilize this feature, as it
  459.     **    calls CLVInitialize.
  460.     **
  461.     **
  462.     **    A number of developers have expressed a desire to have the List Manager support
  463.     **    variable-size cells.  In response to this, the List control has been extended to
  464.     **    support variable-size rows and columns.
  465.     **
  466.     **    The first problem is where to store the size for each row and column.  This
  467.     **    implementation expects the sizes for the individual column widths to be stored
  468.     **    in row 0, cells 1 through numCols, and the individual row widths to be stored in
  469.     **    column 0, rows 1 through numRows.  The values are placed in the cells in decimal
  470.     **    ascii.  (This is so that the AppsToGo editor can easily be used to create lists
  471.     **    with variable-size cells.  You just enter the decimal ascii value in the editor.)
  472.     **    Any row or column without a decimal ascii entry for the size will get the regular
  473.     **    size for a cell.
  474.     **
  475.     **    Since row 0 and column 0 are used to store the widths, these cells are not available
  476.     **    in the list.  They are not displayed, and you can not scroll into them.  Due to this,
  477.     **    the list is one column narrower and one row shorter than a regular list.
  478.     **
  479.     **    The variable-size list expects the dataBounds upper-left to be 0,0.  Any other
  480.     **    upper-left for the dataBounds will cause the variable-size list to misbehave.  
  481.     **    A dataBounds other than 0,0 is very rare, and unnecessary, so it seemed better
  482.     **    to not have the code to support it, than to code for a feature almost never used.
  483.     **
  484.     **    Bit 14 of the mode field needs to be set to true for the list to be converted to
  485.     **    a variable-size list.  Also, CLVInitialize() has to be called at some time, or else
  486.     **    the framework will create the list as a regular list.  (Start.c is a good place.)
  487.     **
  488.     **    For the most part, the List control is managed just like the regular List control.
  489.     **    If you need to access the List itself, it is stored in the refCon of the List control.
  490.     **    However, since the List Manager calls aren't expecting the list to be of variable-size
  491.     **    cells, you can't make all of the calls to the List Manager you would normally make.
  492.     **
  493.     **    If you create a regular list, and then place decimal ascii values in row 0 and
  494.     **    column 0 (where needed), you can then directly call CLVVariableSizeCells() for that
  495.     **    list, and it will be converted.  (If you call CLVVariableSizeCells() directly, you
  496.     **    don't actually need to call CLVInitialize(), as it does this for you.)
  497.     **
  498.     **    Below are the List Manager calls, and how they should be handled when using a
  499.     **    variable-size list:
  500.     **
  501.     **
  502.     **    LActivate:
  503.     **        Call CLActivate().
  504.     **
  505.     **    LAddColumn:
  506.     **        Call CLVAddColumn().
  507.     **
  508.     **    LAddRow:
  509.     **        Call CLVAddRow().
  510.     **
  511.     **    LAddToCell:
  512.     **        Okay to call.  Cell won't be drawn, though.  Standard list drawing is disabled
  513.     **        when using variable-size cell mode.  Call CLVDraw() afterwards to draw the cell.
  514.     **
  515.     **    LAutoScroll:
  516.     **        Call CLVAutoScroll().
  517.     **
  518.     **    LCellSize:
  519.     **        New meaning.  You can set the size of a column or row.  To do, do the following:
  520.     **            1)    LGetCell() for the row or column width to change.  Example:
  521.     **                    For column 3,
  522.     **                        short    len, locSize[2];
  523.     **                        Point    cell;
  524.     **
  525.     **                        len = 2 * sizeof(short);
  526.     **                        cell.h = 3;
  527.     **                        cell.v = 0;
  528.     **                        LGetCell(locSize, &len, cell, list);
  529.     **            2)    Set the size (2nd word) to new size (locSize[1] = newSize).
  530.     **            3)    LSetCell(locSize, len, cell, list);
  531.     **            4)    CLVAdjustCellLocs(list)
  532.     **            5)    CLVUpdate(list)
  533.     **
  534.     **    LClick:
  535.     **        Call CLVClick().
  536.     **
  537.     **    LClrCell:
  538.     **        Okay to call.  Cell won't be drawn, though.  Standard list drawing is disabled
  539.     **        when using variable-size cell mode.  Call CLVDraw() afterwards to draw the cell.
  540.     **
  541.     **    LDelColumn:
  542.     **        Call LDelColumn(), followed by CLVAdjustCellLocs() and CLVUpdate().
  543.     **
  544.     **    LDelRow:
  545.     **        Call LDelRow(), followed by CLVAdjustCellLocs() and CLVUpdate().
  546.     **
  547.     **    LDispose:
  548.     **        Don't call it.  Dispose by DisposeControl(CLViewFromList(list)).
  549.     **
  550.     **    LDoDraw:
  551.     **        Don't call it.  The variable-sized control should always have doDraw false.
  552.     **        (You can hide the list by making the control invisible.)
  553.     **
  554.     **    LDraw:
  555.     **        Call CLVDraw().
  556.     **
  557.     **    LFind:
  558.     **        Okay to call.
  559.     **
  560.     **    LGetCell:
  561.     **        Okay to call.
  562.     **
  563.     **    LGetSelect:
  564.     **        Okay to call.
  565.     **
  566.     **    LLastClick:
  567.     **        Okay to call.
  568.     **
  569.     **    LNextCell:
  570.     **        Okay to call.
  571.     **
  572.     **    LRect:
  573.     **        Call CLVGetCellInfo().
  574.     **        It's overkill, since it gets everything, but tough.  There aren't too many
  575.     **        occasions for the app to get the cell rect, so I'm not going to have another
  576.     **        call to do it.
  577.     **
  578.     **    LScroll:
  579.     **        Don't call.
  580.     **
  581.     **    LSearch:
  582.     **        Okay to call.
  583.     **
  584.     **    LSetCell:
  585.     **        Okay to call.  Cell won't be drawn, though.  Standard list drawing is disabled
  586.     **        when using variable-size cell mode.  Call CLVDraw() afterwards to draw the cell.
  587.     **
  588.     **    LSetSelect:
  589.     **        Call CLVSetSelect().
  590.     **
  591.     **    LUpdate:
  592.     **        Call CLVUpdate
  593.     */
  594.  
  595. void            CLVVariableSizeCells(ListHandle list);
  596.     /*
  597.     **    ¶ Convert a List control to one that has variable size rows and columns.
  598.     **
  599.     **    INPUT:    list        List to convert to variable-size cells.
  600.     **
  601.     **    This is called to convert a List control to one that has variable size rows and columns. */
  602.  
  603. void            CLVAdjustScrollBars(ListHandle list);
  604.     /*
  605.     **    ¶ Adjust the scrollbars to reflect new list size.
  606.     **
  607.     **    INPUT:    list        List whose scrollbars need adjusting.
  608.     **
  609.     **    After doing other operations, call this to adjust the scrollbars to reflect the
  610.     **    the new List size. */
  611.  
  612. void            CLVFindCell(ListHandle list, Point mouseLoc, Point *cell);
  613.     /*
  614.     **    ¶ Given a mouse location, find the cell that contains it.
  615.     **
  616.     **    INPUT:    list        List to examine.
  617.     **            mouseLoc    Point to find the cell for.
  618.     **    OUTPUT:    cell        Cell containing the mouseLoc point.
  619.     **
  620.     **    Since cells are of variable size, it is more difficult to determine which cell contains
  621.     **    a particular point.  CLVFindCell will do this.  If in fact the point is not contained by
  622.     **    any cell, -1, -1 is returned. */
  623.  
  624. void            CLVGetCellRect(ListHandle list, short xx, short yy, Rect *cbnds);
  625.     /*
  626.     **    ¶ Given a cell xx,yy, return its bounding rect.
  627.     **
  628.     **    INPUT:    list        List to get bounding rect for.
  629.     **            xx            Column of cell.
  630.     **            yy            Row of cell.
  631.     **    OUTPUT:    cbnds        Bounding rect of cell.
  632.     **
  633.     **    Get the bounding rect of a cell.  If that cell is invisible, then the rect returned
  634.     **    will be the empty rect. */
  635.  
  636. void            CLVGetVisCells(ListHandle list, Rect *visRct);
  637.     /*
  638.     **    ¶ Get the bounding rect of the cells visible within the Control's view rect.
  639.     **
  640.     **    INPUT:    list        List to get visible-area bounding rect for.
  641.     **    OUTPUT:    visRct        Rect bounding all cells visible within control.
  642.     **
  643.     **    This call is used instead of the visRect field of a list. */
  644.  
  645. void            CLVGetCellInfo(ListHandle list, short xx, short yy, Rect *cbnds, short *cellNum,
  646.                                short *select, short *ofst, short *len);
  647.     /*
  648.     **    ¶ Get plenty of information on a particular cell.
  649.     **
  650.     **    INPUT:    list        List to get info on.
  651.     **            xx            Column of cell to get info on.
  652.     **            yy            Row of cell to get info on.
  653.     **    OUTPUT:    cbnds        Bounding rect of cell.
  654.     **            cellNum        Number of cell in list.
  655.     **            select        True if cell is selected.
  656.     **            ofst        Offset into the data area for cell's data.
  657.     **            len            Length of cell's data.
  658.     **
  659.     **    This call is really more for the variable-list code.  You may find it useful, however. */
  660.  
  661. void            CLVSetSelect(Boolean select, Point cell, ListHandle list);
  662.     /*
  663.     **    ¶ Set the select state for a variable-size cell.
  664.     **
  665.     **    INPUT:    select        Desired select state (true or false).
  666.     **            cell        Cell to set select state for.
  667.     **            list        List containing cell to set select state for.
  668.     **
  669.     **    Whenever you have a variable-cell-size list, use this instead of LSetSelect. */
  670.  
  671. void            CLVAutoScroll(ListHandle list);
  672.  
  673. void            CLVAdjustCellLocs(ListHandle list);
  674.  
  675. short            CLVAddColumn(short count, short colNum, short ww, ListHandle list);
  676.     /*
  677.     **    ¶ Add a column to a variable-size cell.
  678.     **
  679.     **    INPUT:    short        Number of columns to add.
  680.     **            colNum        Column number to insert new columns into.
  681.     **            ww            Width of new column(s).
  682.     **            list        List to add new column(s) to.
  683.     **
  684.     **    Use this instead of LAddColumn. */
  685.  
  686. short            CLVAddRow(short count, short rowNum, short hh, ListHandle list);
  687.     /*
  688.     **    ¶ Add a row to a variable-size cell.
  689.     **
  690.     **    INPUT:    short        Number of rows to add.
  691.     **            rowNum        Row number to insert new columns into.
  692.     **            hh            Height of new rows(s).
  693.     **            list        List to add new rows(s) to.
  694.     **
  695.     **    Use this instead of LAddRow. */
  696.  
  697. void            CLVDraw(Point cell, ListHandle list);
  698.     /*
  699.     **    ¶ Draw a single variable-size cell.
  700.     **
  701.     **    INPUT:    cell        Cell to draw.
  702.     **            list        List containing cell to draw.
  703.     **
  704.     **    Draw a single variable-size cell. */
  705.  
  706. Boolean            CLVClick(Point mouseLoc, short modifiers, ListHandle list);
  707.     /*
  708.     **    ¶ Handle a mouseDown for a variable-cell-size list control.
  709.     **
  710.     **    INPUT:    mouseLoc    The click location the list needs to handle.
  711.     **            modifiers    Event record 
  712.     **            list        The list which is to receive the mouse click.
  713.     **    RESULT:    Boolean        True if user double-clicked on cell.
  714.     **
  715.     **    This is used instead of calling LClick.  You probably don't need to call it diretly, as you
  716.     **    would call CLClick or CLEvent.  CLClick (and possibly CLEvent) would call this if the list
  717.     **    was a variable-cell-size list. */
  718.  
  719. void            CLVUpdate(RgnHandle clipRgn, ListHandle list);
  720.     /*
  721.     **    ¶ Draw the variable-cell-size list control in the correct mode.
  722.     **
  723.     **    INPUT:    clipRgn        Draw only within this region.
  724.     **            list        List to draw.
  725.     **
  726.     **    Draw the variable-cell-size list control in the correct mode. */
  727.  
  728. void            CLVCallDefProc(short lMessage, short lSelect, Rect *lRect, Cell lCell,
  729.                                short lDataOffset, short lDataLen, ListHandle list);
  730.     /*
  731.     **    ¶ Calls the variable-cell-size list's LDEF.
  732.     **
  733.     **    INPUT:    clipRgn        Draw only within this region.
  734.     **            list        List to draw.
  735.     **
  736.     **    Calls the variable-cell-size list's LDEF. */
  737.  
  738.  
  739.  
  740. #ifdef __cplusplus
  741. }
  742. #endif
  743.  
  744.  
  745.  
  746. typedef void            (*CLActivateProcPtr)(Boolean active, ListHandle listHndl);
  747. typedef Boolean            (*CLClickProcPtr)(WindowPtr window, EventRecord *event, short *action);
  748. typedef ControlHandle    (*CLCtlHitProcPtr)(void);
  749. typedef ListHandle        (*CLFindActiveProcPtr)(WindowPtr window);
  750. typedef Boolean            (*CLKeyProcPtr)(WindowPtr window, EventRecord *event);
  751. typedef ControlHandle    (*CLNextProcPtr)(WindowPtr window, ListHandle *listHndl, ControlHandle ctl, short dir, Boolean justActive);
  752. typedef ControlHandle    (*CLViewFromListProcPtr)(ListHandle listHndl);
  753. typedef ListHandle        (*CLWindActivateProcPtr)(WindowPtr window, Boolean displayIt);
  754.  
  755. typedef void            (*CLVVariableSizeCellsProcPtr)(ListHandle list);
  756. typedef void            (*CLVGetCellRectProcPtr)(ListHandle list, short xx, short yy, Rect *cbnds);
  757. typedef void            (*CLVUpdateProcPtr)(RgnHandle clipRgn, ListHandle list);
  758. typedef void            (*CLVAutoScrollProcPtr)(ListHandle list);
  759. typedef void            (*CLVSetSelectProcPtr)(Boolean select, Point cell, ListHandle list);
  760. typedef Boolean            (*CLVClickProcPtr)(Point mouseLoc, short modifiers, ListHandle list);
  761. typedef void            (*CLVAdjustScrollBarsProcPtr)(ListHandle list);
  762.  
  763.  
  764. #define rListCtl        4016
  765.  
  766. #define clHScroll        0x0002
  767. #define clVScroll        0x0008
  768. #define clActive        0x0020
  769. #define clShowActive    0x0040
  770. #define clKeyPos        0x0080
  771. #define clTwoStep        0x0100
  772. #define clHasGrow        0x0200
  773. #define clVariable        0x4000
  774. #define clDrawIt        0x8000
  775.  
  776. #endif
  777.